<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script>
			let dataArry = [
				{id: 1, value: '值1'},
				{id: 2, value: '值2'},
				{id: 3, value: '值3'},
				{id: 1, value: '值4'},
				{id: 2, value: '值5'},
			]
			
			function classify(arr) {
				let map = {};
				let myArr = [];
				for (var i = 0; i < arr.length; i++) {
					if(!map[arr[i].id]){
						myArr.push({
							id:arr[i].id,
							data:[arr[i]]
						})
						map[arr[i].id] = arr[i]
					} else {
						for (var j = 0; j < myArr.length; j++) {
							if(arr[i].id === myArr[j].id){
								myArr[j].data.push(arr[i]);
								break
							}
						}
					}
				}
				return myArr
			}
			
			console.log(classify(dataArry))
		</script>
	</body>
</html>